package cn.tedu.jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class JDBCDemo4 {
    public static void main(String[] args) {
        try {
            Connection connection = DBUtil.getConnection();
            Statement statement = connection.createStatement();
            Scanner scanner = new Scanner(System.in);
            String username = scanner.nextLine();
            String sql = "delete from userinfo where username = " + "'" + username + "'";
            int i = statement.executeUpdate(sql);
            if (i > 0) {
                System.out.println("删除成功");
            }else {
                System.out.println("删除失败");
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
